<template>
	<view class="content" :style="{'--color':color}">

		<status-bar title='收到礼物是否接受' goHome='1'></status-bar>
		<view class="viewbox auto m-top20 bgwhite p-top30 p-bot30 p-left20 p-right20 d-flex bor_radius_10"
			v-if="pageData.length > 0">
			<view class="headImg">
				<image :src="$imgUrls(shareUserInfo.v_headimg)" class="wh bor_radius_10"></image>
			</view>
			<view class="d-flex f-column m-left30">
				<view class="d-flex">
					<text class="color_33 size30">您的朋友~</text>
					<text class="size30" :style="{color:color}">（{{shareUserInfo.v_name}}）</text>
				</view>
				<text class="color_33 size30">赠送您一份礼物</text>
			</view>
		</view>


		<block v-for="(item,index) in pageData" :key="index">
			<view class="viewbox auto m-top20 bgwhite padding20 d-flex bor_radius_10 ">
				<view class="product_Img f-shrink-0 p-re">
					<image :src="$imgUrls(item.pdtimg)" mode="aspectFill" class="bor_radius_10"></image>
					<view class="h7 white numId p-top4 p-bot4 p-left14 p-right14">{{item.id}}</view>
				</view>
				<view class="d-flex f-column m-left30 j-sb">
					<text class="color_33 size30 ellipsis">{{item.pdtname}}</text>
					<view class="d-flex" v-if="item.pdt_spec">
						<text class="color_99 h6 f-shrink-0">规格：</text>
						<text class="color_33 h6 m-left10 ellipsis">{{item.pdt_spec}}</text>
					</view>
					<view class="d-flex">
						<text class="color_99 h6">数量：</text>
						<text class="color_33 h6 m-left10">X{{item.pdt_num}}</text>
					</view>
				</view>
			</view>
		</block>
		<!-- <chickOrder></chickOrder> -->
		<block v-if="pageData.length > 0">
			<view class="viewbtn auto bgcolor m-top150 d-flex a-center j-centert white size36 bold"
				@click="confirm_Btn()">接受</view>
			<view class="viewbtn auto cancel m-top50 d-flex a-center j-centert color_80 size36"
				@click="$common.backHome">没想好</view>
		</block>

		<view class="row j-centert a-center m-top150 m-bot100" v-if="pageTitle.length > 0">
			<view class="d-flex a-center" @click="$common.backHome">
				<text class="color_80 size30">{{pageTitle[0].title}}</text>
				<view class="iconfont icon-xiangyouxiayiye h7 color_80 m-left16"></view>
			</view>
			<view class="viewCenter m-left50 m-right50"></view>
			<view class="d-flex a-center" @click="$rectTo('/pages/user/user')">
				<text class="color_80 size30">{{pageTitle[1].title}}</text>
				<view class="iconfont icon-xiangyouxiayiye h7 color_80 m-left16"></view>
			</view>
		</view>


		<showModel @cancelFunc='showModal=false' goHome='0' v-if='showModal' type='2'></showModel>


	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex';

	import chickOrder from '../warehouse/components/chickOrder.vue'
	// import API from '@/api/user/index.js';
	export default {
		components: {
			chickOrder
		},
		data() {
			return {
				fromShare: 0,
				imgUrl: this.imgUrl,

				showModal: false,


				ids: '',
				share_v_id: '',
				userkey: '',
				pageData: [],
				pageTitle: [],
				shareUserInfo: {}
			}
		},
		onLoad(e) {
			let that = this;
			if (e.ids) that.ids = e.ids;
			if (e.share_v_id) that.share_v_id = e.share_v_id;
			if (e.userkey) that.userkey = e.userkey
			if (e.fromShare) that.fromShare = e.fromShare;
		},
		onShow() {
			let that = this;

			that.getWarehouseGiveInfo();
		},
		methods: {
			// 批量获得赠送商品详情
			getWarehouseGiveInfo() {
				let that = this;
				uni.showLoading({
					title: '加载中~'
				})
				that.$http.post({
					url: '/singleSaleWarehouseApi/getWarehouseGiveInfo',
					data: {
						giveId: that.ids,
						userkey: that.userkey
					}
				}).then(res => {
					uni.hideLoading();
					if (res.errcode != '100') return that.$Toast(res.msg);
					that.pageData = res.data;
					that.pageTitle = res.pageTitle;
					that.shareUserInfo = res.shareUserInfo;
				})
			},


			//确认获取当前赠送
			confirm_Btn() {
				let that = this;
				if (!that.vid) return that.showModal = true;
				uni.showLoading({
					title: '接受中~'
				})
				that.$http.post({
					url: '/singleSaleWarehouseApi/confirmGive',
					data: {
						ids:that.ids,
						giveId: that.ids,
						userkey: that.userkey,
						share_v_id:that.share_v_id
					}
				}).then(res => {
					uni.hideLoading();
					if (res.errcode != '100') return this.$Toast(res.msg);
					uni.showToast({
						title: res.msg,
						icon: 'none',
						success: () => {
							setTimeout(() => {
								uni.navigateTo({
									url: '/warehouse/house'
								})
							}, 800)
						}
					})
				})
			},

		
		},
		computed: {
			...mapState(['color', 'vid', 'bid','share_v_id']),
		}
	}
</script>

<style lang="scss">
	page {
		background: #f7f9fa;
	}

	.headImg {
		width: 80rpx;
		height: 80rpx;
		border: 6rpx solid var(--color);
		border-radius: 50%;
		-webkit-border-radius: 50%;
		overflow: hidden;
	}


	.cancel {
		background: #f5f5f5;
	}

	.viewCenter {
		width: 4rpx;
		height: 32rpx;
		background: #999999;
	}

	.product_Img {
		width: 140rpx;
		height: 140rpx;
	}

	.numId {
		position: absolute;
		right: 0;
		top: 0;
		background: var(--color);
		border-radius: 0 10rpx 0 10rpx;
	}

	.Package {
		width: 30rpx;
		height: 30rpx;
		border: 1rpx solid #CCCCCC;
		border-radius: 50%;
		-webkit-border-radius: 50%;
	}

	.packActive {
		border: 1rpx solid var(--color) !important;
		background: var(--color) !important;
	}
</style>